package com.scsj.supermarket.view.fragment.followmodel;


import android.os.Bundle;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.scsj.supermarket.R;
import com.scsj.supermarket.adapter.FollowShopAdapter;
import com.scsj.supermarket.utils.SkipUtils;
import com.scsj.supermarket.view.activity.personalsettingmodel.MyFollowActivity;
import com.scsj.supermarket.view.fragment.basemodel.BaseFragment;

import java.util.ArrayList;
import java.util.List;

/**
 * 店铺关注
 */
public class FollowShop extends BaseFragment implements View.OnClickListener {
    private MyFollowActivity myFollowActivity;
    private LinearLayout filtrate_ll;

    private RecyclerView recyclerview;
    private FollowShopAdapter followShopAdapter;

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {

        View view = inflater.inflate(R.layout.fragment_follow_shop, null);

        myFollowActivity = (MyFollowActivity) getContext();
        myFollowActivity.initFilter();

        initView(view, null);
        initListener();
        initData();

        return view;
    }

    @Override
    protected void initView(View view, Bundle savedInstanceState) {
        filtrate_ll = view.findViewById(R.id.filtrate_ll);

        recyclerview = view.findViewById(R.id.recyclerview);
        recyclerview.setLayoutManager(new LinearLayoutManager(getHoldingActivity()));
        followShopAdapter = new FollowShopAdapter(getHoldingActivity());
        recyclerview.setAdapter(followShopAdapter);
    }

    @Override
    protected void initListener() {
        filtrate_ll.setOnClickListener(this);
        followShopAdapter.setOnItemClickListener(new BaseQuickAdapter.OnItemClickListener() {
            @Override
            public void onItemClick(BaseQuickAdapter adapter, View view, int position) {
                SkipUtils.toShop(getHoldingActivity());
            }
        });
    }

    @Override
    protected void initData() {
        List<String> list = new ArrayList<>();
        list.add("益联益家");
        list.add("Apple产品专营店");
        list.add("幸运叶子旗舰店");
        followShopAdapter.addData(list);

    }

    @Override
    protected int getLayoutId() {
        return 0;
    }


    @Override
    public void onClick(View view) {
        switch (view.getId()) {
            case R.id.filtrate_ll://筛选
                myFollowActivity.showFilter();
                break;
            default:
                break;
        }
    }
}
